<template>
  <div class="container">
    <div class="top">
      <h3>边框线条环绕流动效果</h3>
      <div class="author">大剑师兰特, 还是大剑师兰特，gis-dajianshi</div>
    </div>
    <div class="dajianshi">
      微信：gis-dajianshi
      <span class="line"></span>
      <span class="line"></span>
      <span class="line"></span>
      <span class="line"></span>
    </div>
  </div>
</template>

<script>
export default {
  name: "animate-border-line",
  components:{}
}
</script>

<style scoped>
.container {
  width: 1000px;
  height: 580px;
  margin: 50px auto;
  border: 1px solid green;
  position: relative;
}

.top {
  margin: 0 auto 0px;
  padding: 10px 0;
  background: indianred;
  color: #fff;
}

.dajianshi {
  width: 420px;
  height: 210px;
  margin: 100px auto;
  line-height: 210px;
  text-align: center;
  font-size: 40px;
  position: relative;
  overflow: hidden;
}

.line {
  position: absolute;
}

/*第一条线*/
.line:nth-child(1) {
  top: 0;
  left: 0;
  width: 100%;
  height: 15px;
  background: linear-gradient(90deg, transparent, blue);
  animation: animate1 8s linear infinite;
}

@keyframes animate1 {
  0% {
    left: -100%;
  }
  50%,
  100% {
    left: 100%;
  }
}

/*第二条线*/
.line:nth-child(2) {
  top: -100%;
  right: 0;
  width: 15px;
  height: 100%;
  background: linear-gradient(180deg, transparent, red);
  animation: animate2 8s linear infinite;
  /* 注意要加上延时触发动画效果，这样线条才会依次触发 */
  animation-delay: 2s;
}

@keyframes animate2 {
  0% {
    top: -100%;
  }

  50%,
  100% {
    top: 100%;
  }
}

/*第三条线*/
.line:nth-child(3) {
  bottom: 0;
  right: 0;
  width: 100%;
  background: linear-gradient(270deg, transparent, orange);
  animation: animate3 8s linear infinite;
  animation-delay: 4s;
}

@keyframes animate3 {
  0% {
    right: -100%;
    height: 15px;
  }

  50%,
  100% {
    height: 10px;
    right: 100%;
  }
}

/*第四条线*/
.line:nth-child(4) {
  bottom: -100%;
  left: 0;
  width: 15px;
  height: 100%;
  background: linear-gradient(360deg, transparent, #f0f);
  animation: animate4 8s linear infinite;
  animation-delay: 6s;
}

@keyframes animate4 {
  0% {
    bottom: -100%;
  }

  50%,
  100% {
    bottom: 100%;
  }
}
</style>
